Skip to content

feat(ui,http,cli,docs): the daemon serves a web console at / with operator sign-in - #289

Merged
V3RON merged 3 commits into
task/270from
task/271
Oct 3, 2026
Merged

V3RON merged 3 commits into
task/270from
task/271

Conversation

@V3RON

@V3RON V3RON commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #271

Stacked on #288 (task/270).

With http.enabled, the daemon serves a web console at / in both modes. An operator signs in with an operator token and sees the shell: header, navigation for Workers, Leases, Waiting, Attention and Events (each "Coming soon"), and Sign out. simlock status and daemon start print Console: <url>, from the new optional status.get field daemon.consoleUrl.

  • ui/: React + Vite app, built into dist/ui by pnpm build. Views and nav entries are one list in ui/src/views/index.tsx. Data goes through ui/src/api.ts: same origin, bearer token, 10 s timeout, and a 401 signs out.
  • src/http/server.ts: serves dist/ui in front of app.fetch with the ADR 0011 CSP and cache headers. Console requests skip the request log, and the daemon warns once at start when the console is not built.
  • pnpm test:console: a Playwright lane in Chromium, Firefox and WebKit, with a new CI job.
  • Docs: docs/CONSOLE.md (user) and docs/internal/DESIGN.md (style guide).

src/core/instance-identity.test.ts › "hands every daemon racing to write the first identity the same one" fails on this machine. It fails the same way on the base commit (task/270), so it is not from this change.

Done when

  • pnpm build produces dist/ui, and the packed tarball contains it. Checked with pnpm build, then pnpm pack --dry-run, which lists dist/ui/index.html and its assets.
  • Opening the address simlock status prints shows the sign-in screen, on a gateway and on a single host. Covered by the browser lane's serving tests and e2e/console-serving.test.ts.
  • An operator token signs in, and agent, worker and unknown tokens are refused with the ADR 0011 §6 messages. Covered by the browser lane's sign-in tests. The "starting" and "unreachable" states are in ui/src/sign-in-check.test.ts.
  • No request goes to any other host. Covered by the page makes no request to any host but the daemon, which also fails on any CSP violation.
  • The browser lane passes in CI in all three browsers. The Console job passed on this PR, and the lane passes locally in all three (57 of 57).
  • docs/CONSOLE.md and docs/internal/DESIGN.md exist and match what was built.

Review

Spec review: 14 findings, 5 fixed. Code review: 14 findings, 13 fixed.

Rejected:

  • "The daemon cannot be reached" shown on a non-2xx from /v1/healthz. The daemon always answers that route with 200, so any other answer there (a proxy's 502) means the daemon was not reached.
  • The sign-in check has a sixth state, "answered with an error (HTTP n)". The ADR 0011 §6 table has no row for answers like a 500; without this state, the screen would say nothing.
  • A "Page not found" view was not asked for. Every path with no extension serves the page (ADR 0011 §3), so an unknown path has to render something.
  • A path under /assets/ with no extension answers 404 rather than the page. Serving the page there gave index.html an immutable cache and answered a missing asset with the page, against ADR 0011 §3 and §4.
  • The shell calls GET /v1/workers on mount. ADR 0011 §6 says a 401 at any time signs out; this call is how a revoked token is signed out on reload. It shows no data.
  • Edits to README, CLI.md, CONFIGURATION.md, ARCHITECTURE.md, .fallowrc.json, and a favicon were not asked for. README lists every end-user doc. The doc edits fix claims this change made false. The fallow entries and the favicon are what the new files need.
  • docs/internal/agent-rules/documentation.md gains docs/CONSOLE.md. Rule 2 names every end-user doc it covers, so a new one joins the list (architecture rule 13).
  • server.ts imports node:fs (raised twice, once per review). ADR 0011 §3 puts file serving in server.ts, the impure HTTP adapter, which already reads the disk through serveStatic.

Written by an agent.

V3RON added 3 commits October 2, 2026 23:53
…rator sign-in

Implements ADR 0011: a React and Vite app in ui/, built into dist/ui and
served in front of app.fetch with the CSP and cache headers; sign-in with
an operator token kept per tab; the shell with its navigation; status.get's
daemon.consoleUrl, printed by simlock status and daemon start; a Playwright
browser lane in Chromium, Firefox and WebKit; CONSOLE.md and DESIGN.md.

Closes #271
@V3RON
V3RON merged commit b122a70 into main Oct 3, 2026
15 checks passed
V3RON added a commit that referenced this pull request Oct 3, 2026
Closes #272

Stacked on #289 (#271).

The console now has live data and the Workers pages.

- **Live data layer** (`ui/src/live/`). `LiveConnection` follows `GET
/v1/events/stream` read with `fetch`, refetches every route the screen
reads on each event and every second, with one request per route in
flight. It marks the console disconnected on a network failure, a 10 s
timeout, a closed stream or 40 s of silence, then asks `/v1/healthz`
after 1, 2, 4, 8 s and every 10 s. The clock offset comes from the
`Date` header. A hidden tab closes the stream and stops polling. Views
use `useLiveResource(path)`, `useNow()` and `useConnection()`.
`useLiveEvents` and `useStreamOpened` are there for the events view.
- **Views**: the workers list and one worker's page (devices, host,
catalog, installs), and a connection line under the header. A `501
UNSUPPORTED_IN_WORKER_MODE` shows "Not available on a single host".
- **Spec gap**: the worker view has no time-in-state for `ready`,
`quarantined` or `shutdown` devices, so those show `—`.
- `docs/CONSOLE.md`, `DESIGN.md` and `ARCHITECTURE.md` are updated.

Known failure: `instance-identity` "racing to write the first identity"
also fails on the base.

## Done when

- [x] A gateway with two fake-driver workers matches `simlock worker
list`, and a lease taken with the CLI shows within a second. Checked by
the browser tests "on a gateway, every worker…" and "a granted lease
shows on the worker within a second". The second starts when the
gateway's own `GET /v1/workers` has the lease.
- [x] A single host shows one worker with the same views. Checked by "on
a single host, the workers view shows one worker". Every detail test
runs on a single host.
- [x] Stopping and starting the daemon follows ADR 0013 §5. Checked by
unit tests for each disconnect cause, the backoff, recovery and
"starting", and by the stop and start browser tests.
- [x] The browser lane passes in Chromium, Firefox and WebKit: `pnpm
test:console` passed 93 of 93, and 558 of 558 with `--repeat-each 6`.

## Review

Spec review: 8 findings, 3 fixed; second round 9 findings, 2 fixed. Code
review: 15 findings, 15 fixed; second round 10 findings, 8 fixed.

Rejected:

- Time in state is missing for `ready`, `quarantined` and `shutdown`
devices. The worker view has no time for them, and the spec allows no
contract change. Spec needs: the time each device entered its state, on
status devices.
- The "within a second" tests start counting when the gateway's own data
has the change. The console cannot show a fact before its daemon has it,
and the gateway took 3 to 12 ms.
- The unit test "durations use the clock offset…" checks only
`serverNow()`. The device browser test now checks shown durations with
the browser clock set 3 hours ahead.
- The shell keyboard test skips controls inside `#main`. The workers
view adds links there, and the test covers the shell's own controls.
- `useLiveEvents` and `useStreamOpened` have no caller yet. The spec
says later views use this layer, and #276 uses them.
- `DESIGN.md` and `ARCHITECTURE.md` are not named in the spec.
Architecture rule 13 requires updating the docs a change affects, and
`DESIGN.md` must change with the styles.
- While the daemon is starting, a timeout retries rather than
disconnecting. ADR 0011 §6 and 0013 §5 call a daemon whose `/v1/healthz`
answers but whose reads wait "starting". A network failure still
disconnects.
- A tab shown again while disconnected asks `/v1/healthz` at once. ADR
0013 §3 says a shown tab catches up at once, and the backoff was paused
while the tab was hidden.
- A worker that reconnects can show a long time in state until the
gateway refreshes it. That refresh follows the connect within
milliseconds.

Restack note: #288 now keeps `worker.list`'s catalog for 30 seconds, so
`docs/CONSOLE.md` says the Workers page's catalog is read again after a
component install and otherwise every 30 seconds (commit `docs(ui): say
when the Workers page's catalog is read again`).

*Written by an agent.*
@V3RON
V3RON deleted the task/271 branch November 6, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Console: served at / with operator sign-in

1 participant